#include "stdafx.h"
#include "DxCamera.h"

CDxCamera::CDxCamera(void)
{
	D3DXMatrixIdentity( &m_mxView );
	D3DXMatrixIdentity( &m_mxProject );
	D3DXMatrixIdentity( &m_mxFinal );

	D3DXQuaternionIdentity( &m_qOrientation );
	m_vEye = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	m_fFOV	= D3DX_PI * 0.25f;
	m_fFar	= 10000.0f;
	m_fNear	= 1.0f;
	m_fAspect= 1.0f; 

	Updata();
}


CDxCamera::~CDxCamera(void)
{ 
}

void CDxCamera::Updata()
{
	//D3DXMatrixLookAtLH( &m_mxView, )
	D3DXMATRIX matRot;
	D3DXMATRIX matT;
	D3DXMatrixTranslation( &matT , -m_vEye.x , -m_vEye.y , -m_vEye.z );

	D3DXQUATERNION rot(-m_qOrientation.x, -m_qOrientation.y, -m_qOrientation.z, m_qOrientation.w);
	D3DXMatrixRotationQuaternion(&matRot, &rot);

	m_mxView = matT * matRot;

	D3DXMatrixPerspectiveFovLH( &m_mxProject, m_fFOV , m_fAspect, m_fNear, m_fFar );
	D3DXMatrixMultiply( &m_mxFinal , &m_mxView , &m_mxProject );
}
